package com.danciyixue.boot.dcyx.model.entity;


import com.baomidou.mybatisplus.annotation.EnumValue;
import lombok.Getter;

@Getter
public enum QuestionType {
    //    enum('etcTranslation', 'cteTranslation', 'hearingTranslation')
    ETC_TRANSLATION("etcTranslation", "英译中"),
    CTE_TRANSLATION("cteTranslation", "中译英"), // 必须与数据库值完全一致
    HEARING_TRANSLATION("hearingTranslation", "听力翻译");

    @EnumValue // 这个注解标记要存入数据库的值
    private final String code;

    private final String description;

    QuestionType(String code, String description) {
        this.code = code;
        this.description = description;
    }

    // 可选：添加从数据库值反查枚举的方法
    public static QuestionType fromCode(String code) {
        for (QuestionType type : values()) {
            if (type.code.equals(code)) {
                return type;
            }
        }
        throw new IllegalArgumentException("未知的题目类型: " + code);
    }
}
